<template>
	<view class="login">
		<view class='logo'>
			<image src="../../static/个人中心%20副本_slices/Group@2x.png" mode=""></image>
		</view>
	<view class="banner">
		<view class="title">芊亮洗发</view>
		<text class="desc">呵护从头发开始</text>
	</view>
		<button class=".confirm" open-type="getUserInfo" @getuserinfo="uniLogin">微信授权登录</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {

			}
		},
		onLoad() {

		},
		methods: {
			uniLogin(e) {
				console.log(e)
				// 获取到用户信息
				let {
					avatarUrl,
					nickName
				} = e.detail.userInfo
				uni.login({
					success: async (res) => {
						let code = res.code
						console.log(code)
						
		let data = await	uni.request({
							url: 'http://localhost:3000/api/user/wxlogin',
							method: 'POST',
							data: {
								code,
								nickname: nickName,
								avatar: avatarUrl
							}
						})
							// 保存token
						uni.setStorageSync()
						// 提示登陆信息
					},

				})
			
			

			}
		}
	}
</script>

<style lang='less'>
.login{
	.logo {
	  width: 300rpx;
	  height: 300rpx;
	  box-shadow: 0px 10rpx 30rpx rgba(0, 0, 0, 0.07);
	  border-radius: 42rpx;
	  display: flex;
	  justify-content: center;
	  align-items: center;
     margin: 100rpx auto;
		image{
			width: 200rpx;
			height: 200rpx;
		}
	}

		.confirm {
			width: 600rpx;
			height: 96rpx;
			backgr ound: #FEDC00;
			border-radius: 12rpx;
			margin-top: 42rpx;
		}
		.banner{
			width: 100%;
			view{
				font-size: 36rpx;
				text-align: center;
			}
			text{
				margin-top: 9rpx;
				font-size: 26rpx;
				color: #C0C0C0;
				display: block;
					text-align: center;
			}
		}
	
}
</style>
